#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=5e5+5,inf=1e16,INF=1e17;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+ch-48,ch=getchar();}
	return x*f;
}
int n,k,d,f[N],h[N],nxt[N],cnt[N],idc[N];
vector<int> del[N];

int rt[N],lst[N],ls[N*25],rs[N*25],t[N*25],laz[N*25],idx;

void down(int &x,int k){
	if(!x) x=++idx,t[x]=-inf;
	t[x]+=k;
	laz[x]+=k;
}
void pushdown(int x){
	if(laz[x]!=0){
		down(ls[x],laz[x]);
		down(rs[x],laz[x]);
		laz[x]=0;
	}
}
void modify(int &x,int l,int r,int p,int k){
	if(!x) x=++idx,t[x]=-inf;
	if(l==r){
		t[x]=k;
		return;
	}
	pushdown(x);
	int mid=(l+r>>1);
	if(p<=mid) modify(ls[x],l,mid,p,k);
	else modify(rs[x],mid+1,r,p,k);
	t[x]=max(t[ls[x]],t[rs[x]]);
}

int md[N];
multiset<int > s;

signed main(){
	freopen("holiday.in","r",stdin);
	freopen("holiday.out","w",stdout);
	n=read(),k=read(),d=read(),t[0]=-inf;
	for(int i=1;i<=n;i++) h[i]=read(),md[i]=i%k;
	for(int i=1;i<n;i++) nxt[i]=read();
	for(int i=0;i<k;i++) lst[i]=-INF;

	f[1]=h[1];
	++cnt[md[1]],idc[1]=cnt[md[1]];
	modify(rt[md[1]],1,n,idc[1],f[1]);
	lst[md[1]]=f[1],s.insert(f[1]);
	del[1+nxt[1]+1].emplace_back(1);

	for(int i=2;i<=n;i++){
		int id=md[i];
		for(int p:del[i]){
			int idp=md[p];
			s.erase(s.find(lst[idp]));
			modify(rt[idp],1,n,idc[p],-inf);
			lst[idp]=t[rt[idp]];
			s.insert(lst[idp]);
		}
		if(lst[id]!=-INF){
			s.erase(s.find(lst[id]));
			down(rt[id],-d);
			lst[id]=t[rt[id]];
			s.insert(lst[id]);
		}
		f[i]=h[i]+(*s.rbegin());
		++cnt[id],idc[i]=cnt[id];
		modify(rt[id],1,n,idc[i],f[i]);
		if(lst[id]!=-INF){
			s.erase(s.find(lst[id]));
			lst[id]=t[rt[id]];
			s.insert(lst[id]);
		}
		else{
			lst[id]=t[rt[id]];
			s.insert(lst[id]);
		}
		if(i<n) del[i+nxt[i]+1].emplace_back(i);
	}
	printf("%lld",f[n]);
	return 0;
}